<template>
	<view class="content_auth" v-if="isauth==1">
		<u-alert-tips type="warning" description="当前提交信息正在审核中..." v-if="userdata.status==1 && userdata.grade!=''"></u-alert-tips>
		<u-alert-tips type="warning" :description="'当前提交信息审核未通过!'+nodesc" v-if="userdata.status==3"></u-alert-tips>
		<view class="head">
			实名认证审核
		</view>
		<view class="con">
			 
			 <u-form-item label-width="150" label="姓名">
				 <u-input v-model="userdata.realname"  placeholder="请输入您的姓名" />
			</u-form-item>
			 <u-form-item  label-width="150" label="手机">
				 <u-input v-model="userdata.mobile" type="number"  placeholder="请输入您的手机号码"/>
			 </u-form-item>
			 <u-form-item  label-width="150" label="年级">
				 <u-input  v-model="userdata.grade" placeholder="请输入您的年级" />
			 </u-form-item>
			 <u-form-item  label-width="150" label="班级">
				 <u-input v-model="userdata.class"   placeholder="请输入您的班级"/>
			 </u-form-item>
			 <u-form-item  label-width="150" label="公司名称">
				 <u-input v-model="userdata.company"   placeholder="请输入您的公司名称"/>	 
			 </u-form-item>
		</view>
		
		<view class="desc">
			<u-section title="审核说明" color="rgb(250, 53, 52)" :arrow="false" :right="false"></u-section>
		    <view class="desc1">1、请确认信息是否填写准确</view>
			<view class="desc1">2、审核通过后可正常浏览本小程序</view>
		  </view>
		  
		  <view><u-button type="error" :loading="loading" throttle-time="500" @click="getUserProfile">授权并提交审核</u-button></view>
		  <view style="margin-top: 20rpx;"><u-button type="success"  @click="jumpbar('/pages/index/index')">返回首页</u-button></view>
	</view>
</template>

<script>
	
	export default {
		name:"auth",
		props: {
			isauth:{
				type:Number,
				default:1
			}
			
		},
		data() {
			return {
				loading:false,
				nodesc:"",
				userdata:{},
				pageshow:false,
			}
		},
		

		mounted: function(e) {
	           if (uni.getStorageSync("user")){
				   this.userdata=uni.getStorageSync("user")
				   if (this.userdata.status==3 && this.userdata.nodesc){
				   	this.nodesc="原因:"+this.userdata.nodesc
				   }
			   }
			   
			
		},
		methods: {
			getUserProfile(){
				console.log(this.userdata,200)
				if (this.userdata.realname=="" || this.userdata.realname== null){
					   this.msg("姓名不能为空");return
				}
				
				if (this.userdata.mobile=="" || this.userdata.mobile == null){
					   this.msg("手机不能为空");return
				}
				if (!this.$u.test.mobile(this.userdata.mobile)){
					this.msg("手机格式不正确");return
				}
				if (this.userdata.grade=="" || this.userdata.grade == null){
					   this.msg("年级不能为空");return
				}
				if (this.userdata.class=="" || this.userdata.class == null){
					   this.msg("班级不能为空");return
				}
				
				if (this.userdata.company=="" || this.userdata.company == null){
					   this.msg("公司名称不能为空");return
				}
				
				uni.getUserProfile({
				     desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
				     success: (res) => {
					  
				       this.$u.post('index.php?class=weixin&act=wxLogin', {
						   userinfo:JSON.stringify(res.userInfo),
						   openid: uni.getStorageSync('openid'),
						    userdata:JSON.stringify(this.userdata)
						   }).then(res => {
				       	  if (res.code==0){
				               uni.setStorageSync("user",res.data)
							   uni.setStorageSync("uid",res.data.id)
							   uni.showModal({
							       title: '提示',
								   showCancel:false,
							       content: '提交成功，请等待管理员审核',
							       success: (res)=>  {
							           if (res.confirm) {
							              // this.check_ysmsg();
							           } else if (res.cancel) {
							               
							           }
							       }
							   });
							  
							  
				       	  }else{
				       		  this.msg(res.msg)
				       	  }
				       
				       });
				     }
				})},
			updateuser() {
              
			   this.data.uid=this.user.id
		
			
			   this.$u.post('index.php?class=user&act=updateuser', this.data).then(res => {
			   	  if (res.code==0){
					  uni.setStorageSync("user",res.data)
					  this.user=res.data
					  this.msg("提交成功,请等待审核");
					  //this.jump("/pages/user/list")
				  }else{
					  this.msg(res.msg)
				  }
			   
			   });
			},
			confirm_jc(e) {
			 this.data.jctext=e[0].label
			 this.data.jc=e[0].value
		  },
		
			//内容搜索
			Listen(value) {
				//防抖
				this.$u.throttle(this.listenaction(value), 500)
			},
			listenaction(value) {

				this.$u.post('index.php?class=user&act=search', {
					key: value
				}).then(res => {

					this.keyworkDatas = res.data;

				});
			},
			//列表点击事件
			onItemClick(event) {
				let item = event.item;
				let index = event.index;
				this.data.usertext = item
				this.data.user = this.keyworkDatas[index].id
				this.layershow = false

			},
		}
	}
</script>

<style scoped>
	.desc1{margin: 20rpx auto; color: #999;}
	.content_auth{padding:20rpx;position: fixed;
	background: white;
	width: 100vw;
	height: 100vh;

	z-index: 11111;
	top: 0;}
	.head{font-size: 26px; margin-top: 20px; margin-left: 5px;}
	.con{margin: 40rpx auto;}
</style>
